//数据概览第一个图的代码
// controller/StatisticsController_pmh.java
package com.scuec.groupfive.controller;

import com.scuec.groupfive.service.StatisticsService_pmh;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/statistics")
@CrossOrigin(
        origins = "http://localhost:5173", // 允许的前端源
        methods = {RequestMethod.GET, RequestMethod.POST}, // 允许的请求方法
        allowedHeaders = "*" // 允许所有请求头（可选）
)
public class StatisticsController_pmh {

    @Autowired
    private StatisticsService_pmh statisticsService;

    // 新增：最近30天日均活跃用户
    @GetMapping("/last-30days-dau")
    public Double getLast30DaysDAU() {
        return statisticsService.getLast30DaysDAU();
    }

    // 保留原有人均做题量接口
    @GetMapping("/avg-questions")
    public Double getAvgQuestionsPerUser(
            @RequestParam String startDate,
            @RequestParam String endDate) {
        return statisticsService.getAvgQuestionsPerUser(startDate, endDate);
    }
}